package com.itheima.properties;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/*
把Properties 当做Map来使用

增删改查 遍历
 */
public class Demo01 {

    public static void main(String[] args) {
        Properties prop = new Properties();
        //增
        prop.put(123,123);

        prop.put("小璐","PGone");
        prop.put(true,false);
        System.out.println(prop);
        //删
        prop.remove(true);
        System.out.println(prop);

        //改
        prop.put("小璐","乃亮");
        System.out.println(prop);

        //查
        System.out.println(prop.get(123));
        System.out.println(prop.get("小璐"));
        System.out.println(prop.get(true));
        //遍历键遍历
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            System.out.println(key+"==="+prop.get(key));
        }
        //遍历键值对
        Set<Map.Entry<Object, Object>> entries = prop.entrySet();
        Iterator<Map.Entry<Object, Object>> iterator = entries.iterator();
        while (iterator.hasNext()){
            Map.Entry<Object, Object> entry = iterator.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key+"%%%"+value);
        }
        //foreach()
        prop.forEach((k,v)->{
            System.out.println(k+"####"+v);
        });
    }
}
